package com.cans.lightning.business.lowcode.manager.form.save;

import com.cans.lightning.business.lowcode.manager.form.bean.AppFormBean;
import com.cans.lightning.business.lowcode.manager.form.save.AbstractBeanSaveHandler;
import com.cans.lightning.business.lowcode.manager.form.save.handler.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author cans
 * @date 2023/11/29
 **/
@Component
public class FormDesignSaveHandlerChainBuilder {

    @Resource
    private FormDesignBaseSaveHandler formBeanTableLoader;
    @Resource
    private FormDesignMainTableSaveHandler formDesignMainTableSaveHandler;
    @Resource
    private FormDesignSonTableSaveHandler formDesignSonTableSaveHandler;
    @Resource
    private FormDesignEndSaveHandler formDesignEndSaveHandler;
    @Resource
    private FormDesignViewSaveHandler formDesignViewSaveHandler;

    public AbstractBeanSaveHandler<AppFormBean> getSaveHandlerChain(){
        AbstractBeanSaveHandler<AppFormBean> saveHandler = formBeanTableLoader.nextHandler(formDesignMainTableSaveHandler)
                .nextHandler(formDesignSonTableSaveHandler)
                .nextHandler(formDesignViewSaveHandler);
        saveHandler.nextHandler(formDesignEndSaveHandler);
        return formBeanTableLoader;
    }
}
